package com.handler;

import com.actor.ClusterClientMasterActor;
import com.handler.manager.BasicGameServerPacketHandler;
import com.message.Message.UserInfo;
import com.message.TransformationMessages;

public class GameServerOneHandler extends BasicGameServerPacketHandler {

	public GameServerOneHandler() {
		super((short)1001);
	}

	@Override
	public TransformationMessages.GameServerPacket handle(TransformationMessages.GameServerPacket packet) throws Exception {
		UserInfo info = UserInfo.parseFrom(packet.getBytes());
		UserInfo.Builder res = UserInfo.newBuilder();
		res.setId(1001);
		res.setName("client1 name");
		System.out.println("client 1 receive packet:"+info.getName());
		
		TransformationMessages.GameServerPacket resPacket1 = new TransformationMessages.GameServerPacket((short)1002,res.build().toByteArray(),2);
		ClusterClientMasterActor.getInstance().sendToGameServer(resPacket1);
		TransformationMessages.GameServerPacket resPacket = new TransformationMessages.GameServerPacket((short)100,res.build().toByteArray(),packet.getGameServerId());
		return resPacket;
	}

}
